<script setup lang="ts">
import {onMounted, ref} from 'vue'
import Top from './components/top/index.vue'
import Age from './components/age/index.vue'
import Tourist from './components/tourist/index.vue'
import Sex from './components/sex/index.vue'
import Map from './components/map/Index.vue'
import Line from './components/line/Index.vue'
import Rank from './components/rank/index.vue'
import Year from './components/year/index.vue'
import Couter from '@/views/screen/components/counter/index.vue'
const screen = ref<any>()
onMounted(()=>{
  screen.value.style.transform=`scale(${getScale()}) translate(-50%,-50%)`
})
/**
 * 获取比例尺
 * @param w
 * @param h
 */
const getScale = (w=1920,h=1080) => {
  const ww =window.innerWidth/w
  const wh = window.innerHeight/h
  return ww<wh?ww:wh
}
//根据屏幕大小重新绘制screen区域
window.onresize=()=>{
  screen.value.style.transform=`scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top></Top>
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Couter class="counter"></Couter>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss">
.container{
  width: 100vw;
  height: 100vh;
  background: url("./images/bg.png") no-repeat;
  background-size: cover;
  .screen{
    width: 1920px;
    height: 1080px;
    position: fixed;
    left: 50%;
    top: 50%;
    transform-origin: left top;
    .top{
      width: 100%;
    }
    .bottom{
      display: flex;
      .left{
        flex: 1;
        height: calc(100vh - 40px);
        display: flex;
        flex-direction: column;
        .tourist{
          flex:1;
        }
        .age{
          flex:1;
        }
        .sex{
          flex:1;
        }
      }
      .center{
        flex: 2;
        height: calc(100vh - 40px);
        display: flex;
        flex-direction: column;
        .map{
          flex:2;
        }
        .line{
          flex:1;
        }
      }
      .right{
        flex: 1;
        height: calc(100vh - 40px);
        display: flex;
        flex-direction: column;
        .rank{
          flex:1
        }
        .year{
          flex:1
        }
        .counter{
          flex:1
        }
      }
    }
  }
}
</style>